package com.dr.java.day03;

/**
 * Created by rui on 2017/12/29.
 */
public class Triangle {
    public static void main(String[] args) {
        printTriangle(8, "up");
        System.out.println();
        printTriangle(5, "down");
    }

    private static void printTriangle(int size, String dir) {


        for (int i = 0; i < size; i++) {
            int spaceNum;
            if ("up".equals(dir)) {
                spaceNum = size - i - 1;
            } else {
                spaceNum = i;
            }
            for (int j = 0; j < spaceNum; j++) {
                System.out.print("-");
            }
            for (int j = 0; j < size - spaceNum; j++) {
                System.out.print("* ");
            }
            System.out.println();
        }


    }
}
